import os

# 创建文件夹（如果文件夹不存在）
folder_name = "test_folder"
if not os.path.exists(folder_name):
    os.makedirs(folder_name)

# 在文件夹中创建文件
file_path = os.path.join(folder_name, "example.txt")
with open(file_path, "w") as file:
    file.write("This file is inside a folder.\n")